import 'package:flutter/material.dart';
import 'package:flutter_shop_template/pages/widgets/card/five.dart';

class ClassifyListBrand extends StatefulWidget {
  const ClassifyListBrand({Key? key}) : super(key: key);

  @override
  _ClassifyListBrandState createState() => _ClassifyListBrandState();
}

class _ClassifyListBrandState extends State<ClassifyListBrand> {
  List<String> tabs = [
    "全部",
    "全面屏电视",
    "教育电视",
    "OLED电视",
    "智慧屏4K",
    "超清电视",
    "55英寸",
    "65英寸",
    "电视配件"
  ];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: tabs.length,
      child: Theme(
        data: Theme.of(context).copyWith(),
        child: Scaffold(
          resizeToAvoidBottomInset: false,
          appBar: AppBar(
            title: const Text('种草特辑'),
            actions: [
              IconButton(onPressed: () {}, icon: const Icon(Icons.search))
            ],
            bottom: PreferredSize(
              preferredSize: const Size.fromHeight(48),
              child: Container(
                color: Colors.white,
                child: TabBar(
                  isScrollable: true,
                  labelColor: Colors.indigo,
                  unselectedLabelColor: Colors.black.withOpacity(.75),
                  tabs: tabs
                      .map(
                        (e) => Tab(
                          text: e,
                        ),
                      )
                      .toList(),
                ),
              ),
            ),
          ),
          body: SafeArea(
            child: TabBarView(
                children: tabs
                    .map(
                      (e) => ListView.builder(
                        padding: const EdgeInsets.only(top: 10),
                        itemCount: 12,
                        itemBuilder: (context, index) => CustomCard5(
                          key: Key('$index'),
                          imageUrl:
                              'https://cdn.xihaf.com/template/a$index.jpg',
                        ),
                      ),
                    )
                    .toList()),
          ),
        ),
      ),
    );
  }
}
